package utils;

import java.io.IOException;
import java.io.InputStream;

public class StreamGobbler implements Runnable{
	InputStream is;

	public StreamGobbler(InputStream is) {
		super();
		this.is = is;
	}
	
	@Override
	public void run() {
		int c;
		while (!Thread.currentThread().isInterrupted()){
			try {
				if ((c = is.read()) < 0) return;
				System.out.print((char)c);
			} catch (IOException e) {
				return;
			}
		}
	}
	
	public static void gobble(InputStream is){
		new Thread(new StreamGobbler(is)).start();
	}
}
